<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .cover {
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            background: rgba(0, 0, 0, .5);
        }
    </style>
</head>

<body>
    <button>按钮</button>
    <div class="cover"></div>
    <script>
        // document.querySelector('button').addEventListener('touchstart', () => {
        //   window.timer = setTimeout(() => {
        //     console.log('长按')
        //   }, 2000)
        // })

        // document.querySelector('button').addEventListener('touchend', () => {
        //   clearTimeout(window.timer)
        // })

        document.querySelector('button').addEventListener('click', () => {
            console.log('click')
        })

        document.querySelector('.cover').addEventListener('touchstart', () => {
            console.log('touch start')
            setTimeout(() => {
                document.querySelector('.cover').style.display = 'none'
            }, 200)
        })
    </script>
</body>

</html>